<html>
<head>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <meta charset="utf-8" />
    <style>

    </style>
</head>
<body>

<form class="layui-form" action="" style="margin-top: 20px;margin-right: 30px;">

    <input type="hidden" name="id" value="{$data.id}">
    <div class="layui-form-item">
        <label class="layui-form-label">名称</label>
        <div class="layui-input-block">
            <input type="text" name="name" id="name" required  lay-verify="required" autocomplete="off" class="layui-input" value="{$data.name}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">位置</label>
        <div class="layui-input-block">
            <input type="radio" name="type" value="1" title="现金红包" {if condition="$data.type == 1"}checked{/if}>
            <input type="radio" name="type" value="2" title="优惠券"  {if condition="$data.type == 2"}checked{/if}>
            <input type="radio" name="type" value="3" title="虎牙"  {if condition="$data.type == 3"}checked{/if}>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">金额，优惠券ID或虎牙</label>
        <div class="layui-input-block">
            <input type="text" name="value" id="value" required  lay-verify="required" autocomplete="off" class="layui-input" value="{$data.value}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">数量</label>
        <div class="layui-input-block">
            <input type="text" name="num" id="num" required  lay-verify="required" autocomplete="off" class="layui-input" value="{$data.num}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">数值</label>
        <div class="layui-input-block">
            <input type="text" name="number" id="number" required  lay-verify="required" autocomplete="off" class="layui-input" value="{$data.number}">
        </div>
    </div>


    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
        </div>
    </div>
</form>


<script src="/js/jquery-1.10.1.min.js" type="text/javascript"></script>
<script src="/layui/layui.js"></script>
<script>

    layui.use('form', function(){
        var form = layui.form;
        form.render();

        //监听提交
        form.on('submit(formDemo)', function(data){
            var data = data.field;

            $.post("/ops/redpacket/edit", data, function (res) {
                var res = JSON.parse(res);
                if(res.errno==0){
                    layer.msg('操作成功')
                }

                window.parent.location.reload();
            });
            return false;
        });
    });


    function delete1(a){
        $(a).parent().remove()
    }

</script>


</body>
</html>

